<?php
  echo $this->Html->css('calendar/fullcalendar');
?>
<?php
$this->Paginator->options(array(
    'update' => '#content-outer',
    'evalScripts' => false,
    'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
    'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
));
$pageOption = $this->Paginator->params();
?>
<?php echo $this->Html->image('loading.jpg', array('id' => 'busy-indicator', 'style' => 'display:none;')); ?>

<div id="content">
	<!--  start page-heading -->
	<div id="page-heading">
		<h1><?php echo __('Events');?></h1>
    <?php //echo $this->Html->link("Ticket", array('action' => 'add')); ?>&nbsp;&nbsp;
	</div>
	<!-- end page-heading -->
	<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
  	<tr>
  		<th rowspan="3" class="sized">
          <?php echo $this->Html->image('/images/shared/side_shadowleft.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
      </th>
  		<th class="topleft"></th>
  		<td id="tbl-border-top">&nbsp;</td>
  		<th class="topright"></th>
  		<th rowspan="3" class="sized">
          <?php echo $this->Html->image('/images/shared/side_shadowright.jpg', array('width' => '20', 'height' => '300', 'alt' => '')); ?>
      </th>
  	</tr>
  	<tr>
  		<td id="tbl-border-left"></td>
  		<td>
  		<!--  start content-table-inner ...................................................................... START -->
    		<div id="content-table-inner">
      			<!--  start table-content  -->
      			<div id="table-content">
                <div class="events index">

            				<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
              				<tr>
              					<th class="table-header-repeat line-left minwidth-1">
                             <?php echo $this->Paginator->sort('event_type_id'); ?>
                        </th>
              					<th class="table-header-repeat line-left minwidth-1">
                             <?php echo $this->Paginator->sort('title'); ?>
                        </th>
              					<th class="table-header-repeat line-left minwidth-1">
                             <?php echo $this->Paginator->sort('status'); ?>
                        </th>
              					<th class="table-header-repeat line-left minwidth-1">
                             <?php echo $this->Paginator->sort('start'); ?>
                        </th>
              					<th class="table-header-repeat line-left minwidth-1">
                             <?php echo $this->Paginator->sort('end'); ?>
                        </th>
              					<th class="table-header-repeat line-left minwidth-1">
                             <?php echo $this->Paginator->sort('all_day'); ?>
                        </th>
              					<th class="table-header-repeat line-left">
                             Action
                        </th>          
              				</tr>

                    	<?php
                    	$i = 0;
                    	foreach ($events as $event):
                    		$class = null;
                    		if ($i++ % 2 == 0) {
                    			$class = ' class="altrow"';
                    		}
                    	?>
                    	<tr<?php echo $class;?>>
                    		<td>
                    			<?php echo $this->Html->link($event['EventType']['name'], array('controller' => 'event_types', 'action' => 'view', $event['EventType']['id'])); ?>
                    		</td>
                    		<td><?php echo $event['Event']['title']; ?></td>
                    		<td><?php echo $event['Event']['status']; ?></td>
                    		<td><?php echo $event['Event']['start']; ?></td>
                            <?php if($event['Event']['all_day'] == 0) { ?>
                       		<td><?php echo $event['Event']['end']; ?></td>
                            <?php } else { ?>
                    		<td>N/A</td>
                            <?php } ?>
                            <td><?php if($event['Event']['all_day'] == 1) { echo "Yes"; } else { echo "No"; } ?>&nbsp;</td>
                    		<td class="actions">
                    			<?php echo $this->Html->link(__('View', true), array('action' => 'view', $event['Event']['id'])); ?>
                    			<?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $event['Event']['id'])); ?>
                    		</td>
                    	</tr>
                    <?php endforeach; ?>
                </table>
              	<div class="paging">
                  		<!--  start paging..................................................... -->
                    <? if($pageOption['pageCount'] > 1): ?>	
                      <table border="0" cellpadding="0" cellspacing="0" id="paging-table">
                          <?php echo $this->element('pagination');?>       
                  		</table> 
                  		<!--  end paging................ -->
                    <? endif; ?>	
              	</div>
              </div>
              <div class="actions">
              	<ul>
              		<li><?php echo $this->Html->link(__('New Event', true), array('action' => 'add')); ?></li>
              		<li><?php echo $this->Html->link(__('Manage Event Types', true), array('controller' => 'event_types', 'action' => 'index')); ?> </li>
              		<li><li><?php echo $this->Html->link(__('View Calendar', true), array('controller' => 'calendars', 'action' => 'index')); ?></li>
              	</ul>
              </div>
        		</div>
      <!--  end content-table  -->
    		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id="tbl-border-right"></td>
	</tr>
	<tr>
		<th class="sized bottomleft"></th>
		<td id="tbl-border-bottom">&nbsp;</td>
		<th class="sized bottomright"></th>
	</tr>
	</table>
	<div class="clear">&nbsp;</div>

</div>
<?php
    echo $this->Js->writeBuffer();
?>	
